<?php
$pdbID = '5P21';
$filename = $pdbID.'.pdb';

$structure = "";
if(file_exists('structure/structures'.$filename)) {
	$structure = file_get_contents('structure/structures'.$filename);
} else {
	$structure = file_get_contents('http://www.pdb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId='.$pdbID);
	file_put_contents('structure/structures'.$filename, $structure);
}

header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: text/plain");
header("Content-disposition: attachment; filename=".$filename);

print $structure;
?>